# -*- coding: utf-8 -*-
# @Time    : 2022/7/16 14:54
# @Author  : catherine
# @Email   : catherine_csq@163.com
# @File    : add_customer_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

from pages.base_page import BasePage


class AddCustomerPage(BasePage):
    '''新建客户页面类'''
    url='http://192.168.189.1:8081/crm/index.php?m=customer&a=add'
    #定位器
    remove_locator = (By.ID, 'remove')
    cname_locator = (By.ID, 'name')
    industry_locator = (By.ID, 'industry')
    origin_locator = (By.ID, 'origin')
    ownership_locator = (By.ID, 'ownership')
    zip_code_locator = (By.ID, 'zip_code')
    annual_revenue_locator = (By.ID, 'annual_revenue')
    rating1_locator = (By.ID, 'rating1')
    submit_locator = (By.NAME, 'submit')
    con_qq_locator = (By.NAME, 'con_qq')

    def click_remove(self):
        '''将客户放入客户池'''
        self.find_element(self.remove_locator).click()

    def input_cname(self,cname):
        '''输入客户名称'''
        self.find_element(self.cname_locator).send_keys(cname)

    def input_industry(self,industry):
        '''输入客户行业'''
        industry_list = Select(self.find_element(self.industry_locator))
        industry_list.select_by_visible_text(industry)

    def input_origin(self,origin):
        '''输入客户来源'''
        origin_list = Select(self.find_element(self.origin_locator))
        origin_list.select_by_visible_text(origin)

    def click_ownership(self):
        '''选择公司性质为合资'''
        self.find_element(self.ownership_locator).click()

    def input_zip_code(self,zip_code):
        '''输入邮编'''
        self.find_element(self.zip_code_locator).send_keys(zip_code)

    def input_annual_revenue(self,annual_revenue):
        '''输入年营业额'''
        annual_revenue_list = Select(self.find_element(self.annual_revenue_locator))
        annual_revenue_list.select_by_visible_text(annual_revenue)

    def click_rating1(self):
        '''输入评分，选择一星'''
        self.find_element(self.rating1_locator).click()

    def click_subimt(self):
        '''保存新建联系人'''
        self.find_element(self.submit_locator).click()

    def input_con_qq(self,con_qq):
        '''输入QQ'''
        self.find_element(self.con_qq_locator).send_keys(con_qq)
